package org.kernelab.basis.test;

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;

public class C extends JFrame
{
	/**
	 * 
	 */
	private static final long	serialVersionUID	= 4340392948139130296L;

	public C()
	{
		final JTextArea textArea = new JTextArea(20, 50), lineNumberColumn = new JTextArea(
				" 1 ");

		textArea.getDocument().addDocumentListener(new DocumentListener() {
			public void insertUpdate(DocumentEvent e)
			{
				lineNumberColumn.setText("");
				for (int i = 1; i <= textArea.getLineCount(); i++)
					lineNumberColumn.append(" " + i + " \n");
			}

			public void removeUpdate(DocumentEvent e)
			{
				insertUpdate(e);
			}

			public void changedUpdate(DocumentEvent e)
			{
			}
		});

		lineNumberColumn.setBackground(Color.ORANGE);
		lineNumberColumn.setFocusable(false);

		JScrollPane sp = new JScrollPane(textArea);
		sp.setRowHeaderView(lineNumberColumn);

		getContentPane().add(sp);
		pack();
		setLocation(200, 200);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
	}

	public static void main(String[] args)
	{
		new C();
	}
}
